<?php

namespace App\Http\Controllers\Api\User;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repos\CouponRepo;
use App\Http\Requests\Api\ApiRequest;

class CouponController extends Controller
{
    public function useCoupon(ApiRequest $request)
    {   
        $rs['status']    = true;
    	$data['code']    = trim($request->coupon_code);
        $data['user_id'] = $request->user_id;
    	$flag            = CouponRepo::useCoupon($data);
        //dd($flag);
        if($flag['status'] == false) {
            $rs['status'] = false;
            $rs['msg']    = $flag['msg'];
            return response()->json($rs);
        }    	
    	return response()->json($rs);    	
    }

    /**
     * 充值记录
     */
    public function log(ApiRequest $request)
    {
        $rs['status']    = true;
       
        $where['user_id'] = $request->user_id;
        $data            = CouponRepo::log($where);
        $rs['data'] = $data;
        return response()->json($rs);
    }

    

}
